package com.bianguo.android.apushdemo.presenter.impl;

import com.bianguo.android.apushdemo.entity.AuditEntity;
import com.bianguo.android.apushdemo.model.impl.TestModel;
import com.bianguo.android.apushdemo.utils.MyLog;

import java.io.IOException;

import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import rx.Subscriber;

/**
 * Created by Administrator on 2017/9/8.
 */

public class TestPresenter {

    private TestModel testModel;

    public TestPresenter() {
        testModel = new TestModel();
    }

    public void test(RequestBody body) {
        testModel.test(body, new Subscriber<ResponseBody>() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {
                MyLog.mLog("test error : " + e.getMessage());
            }

            @Override
            public void onNext(ResponseBody responseBody) {
                MyLog.mLog("responseBody == null ? " + (responseBody == null));
                if (responseBody == null) {
                    return;
                }
                try {
                    MyLog.mLog("responseBody = " + responseBody.string());
                } catch (IOException e) {
                    e.printStackTrace();
                }
//                MyLog.mLog("responseBody = " + responseBody.toString());
            }
        });
    }
}
